﻿<?php 

	/*
	header("Cache-Control: max-age=0, no-cache, no-store, must-revalidate");
	header("Pragma: no-cache");
	header("Expires: Wed, 11 Jan 1984 05:00:00 GMT");
	*/
	header("Expires: Wed, 11 Jan 1984 05:00:00 GMT");
	header('Content-type: text/cache-manifest'); 
	//header("refresh:120;url=wherever.php" );
	$hashes = "";
	$nbFichiers = 0;
	
	function printFiles( $path = '.', $level = 0 ){ 
		global $hashes;
		global $nbFichiers;
	  $ignore = array('.', '..','.htaccess','.svn','test.html','manifest.appcache.php','inscription.php','demandeContact.php','nbFichiersManifest.html','Thumbs.db'); 	   
	  //$ignore = array('.', '..','.svn','manifest.appcache.php','inscription.php','demandeContact.php','nbFichiersManifest.html','Thumbs.db');  

	    $dh = @opendir( $path ); 

	    while( false !== ( $file = readdir( $dh ) ) ){ 
	        if( !in_array( $file, $ignore ) ){ 
	            if( is_dir( "$path/$file" ) ){ 
	                printFiles( "$path/$file", ($level+1) ); 
	            } elseif(!empty($file)) { 
					$hashes .= md5_file("$path/$file");
	                echo $path."/".$file."\n";
					$nbFichiers++;
	            } 
	        } 
	    } 

	    closedir( $dh ); 
		
	}
	
	

echo "CACHE MANIFEST\n";

printFiles('.');

$fp = fopen("nbFichiersManifest.html", "w+");
fputs ($fp, "$nbFichiers");
fclose ($fp);

// version hash changes automatically when files are modified
echo "#VersionHash: " . md5($hashes) . "\n";
echo "NETWORK:\n";
echo "./nbFichiersManifest.html\n";
echo "./test.html\n";
echo "FALLBACK:\n";